package cn.hist.hfp.converter;

import cn.hist.hfp.entity.Business;
import cn.hist.hfp.vo.BusinessVO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Component
public class BusinessConverter {

    public BusinessVO convert(Business business) {
        return BusinessVO.builder().id(business.getId()).name(business.getName()).summary(business.getSummary()).build();
    }

    public List<BusinessVO> convert(List<Business> businesses) {
        List<BusinessVO> businessVOS = new ArrayList<>();
        for (Business business: businesses) {
            businessVOS.add(convert(business));
        }
        return businessVOS;
    }

    public Set<BusinessVO> convert(Set<Business> businesses) {
        Set<BusinessVO> businessVOS = new HashSet<>();
        for (Business business: businesses) {
            businessVOS.add(convert(business));
        }
        return businessVOS;
    }
}
